Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

cbor-x

Package Overview
Dependencies
Maintainers
0
Versions
42
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cbor-x

Ultra-fast and conformant CBOR (RFC 8949) implementation with support for numerous tag extensions including records and structured cloning

  • 1.6.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
0
Created

What is cbor-x?

The cbor-x npm package is a fast and efficient library for encoding and decoding data using the CBOR (Concise Binary Object Representation) format. It is designed to handle a wide range of data types and structures, making it suitable for various applications that require compact and efficient data serialization.

What are cbor-x's main functionalities?

Encoding Data

This feature allows you to encode JavaScript objects into CBOR format. The code sample demonstrates encoding a simple object into CBOR.

const cbor = require('cbor-x');
const data = { name: 'Alice', age: 30, isAdmin: true };
const encoded = cbor.encode(data);
console.log(encoded);

Decoding Data

This feature allows you to decode CBOR data back into JavaScript objects. The code sample demonstrates decoding a CBOR buffer back into an object.

const cbor = require('cbor-x');
const encoded = Buffer.from([0xa3, 0x64, 0x6e, 0x61, 0x6d, 0x65, 0x65, 0x41, 0x6c, 0x69, 0x63, 0x65, 0x63, 0x61, 0x67, 0x65, 0x18, 0x1e, 0x67, 0x69, 0x73, 0x41, 0x64, 0x6d, 0x69, 0x6e, 0xf5]);
const decoded = cbor.decode(encoded);
console.log(decoded);

Handling Complex Data Structures

This feature demonstrates the ability to handle complex data structures, including nested objects and arrays. The code sample shows encoding and decoding a more complex object.

const cbor = require('cbor-x');
const data = { name: 'Alice', age: 30, hobbies: ['reading', 'hiking'], address: { city: 'Wonderland', zip: '12345' } };
const encoded = cbor.encode(data);
const decoded = cbor.decode(encoded);
console.log(decoded);

Other packages similar to cbor-x

Keywords

FAQs

Package last updated on 28 Jul 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc